package com.bstek.bdf2.core.security.session;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationListener;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.security.core.session.SessionDestroyedEvent;
import org.springframework.security.core.session.SessionInformation;
import org.springframework.security.core.session.SessionRegistry;

import java.util.List;

/**
 * @Title: 自定义存储session
 * @Package: com.bstek.bdf2.core.security.session
 * @Description:
 * @Author: zxq
 * @Date: 2023/12/8 - 15:01
 */
public class RedisSessionRegistryImpl  implements SessionRegistry, ApplicationListener<SessionDestroyedEvent> {
    protected final Logger logger = LoggerFactory.getLogger(RedisSessionRegistryImpl.class);

    private RedisTemplate redisTemplate;

    public RedisSessionRegistryImpl(RedisTemplate redisTemplate) {
        this.redisTemplate = redisTemplate;
    }


    @Override
    public void onApplicationEvent(SessionDestroyedEvent sessionDestroyedEvent) {
        String sessionId = sessionDestroyedEvent.getId();
        removeSessionInformation(sessionId);
    }

    @Override
    public List<Object> getAllPrincipals() {
        return null;
    }

    @Override
    public List<SessionInformation> getAllSessions(Object o, boolean b) {
        return null;
    }

    @Override
    public SessionInformation getSessionInformation(String s) {
        return null;
    }

    @Override
    public void refreshLastRequest(String s) {

    }

    @Override
    public void registerNewSession(String s, Object o) {

    }

    @Override
    public void removeSessionInformation(String s) {

    }
}
